package com.sheep.pattern.chain;

/**
 * @author wangze
 * @date 2021-03-12 10:04.
 **/
public abstract class Handler {

	public Handler getNextHandler() {
		return nextHandler;
	}

	public void setNextHandler(Handler nextHandler) {
		this.nextHandler = nextHandler;
	}

	protected  Handler nextHandler;

	/**
	 * 执行操作
	 * @return
	 */
	public abstract boolean handle();

	/**
	 * 执行责任链
	 */
	public final void  execute(){
		if(handle()&&nextHandler!=null){
			nextHandler.execute();
		}
	}
}
